<template>
  <div class="head">
    <div class="head-top">
      <van-icon
        name="arrow-left"
        size="20"
        color="#323232"
        class="arrow-left"
        @click="handlemy"
      />
      <div class="tj">我的收货地址</div>
    </div>
    <van-address-list
      v-model="chosenAddressId"
      :list="lists"
      default-tag-text="默认地址"
      @add="onAdd(-1)"
      @edit="onEdit"
    />
  </div>
</template>

<script>
import {mapState} from "vuex"
export default {
  data() {
    return {
      chosenAddressId:'',
    };
  },
  methods: {
    onAdd(index) {
      // Toast("新增地址");
    
      this.$router.push({
        path:"/addressedit",
        query:{
          index
        }
      })

    },
    onEdit(item, index) {
      // Toast("编辑地址:" + index);
         this.$router.push({
        path:"/addressedit",
        query:{
          item,
          index
        }
      })
    },
    handlemy(){
      console.log(1)
      this.$router.push('/my')
    }
  },
  computed: {
   lists(){
     return this.$store.state.Dladdress.addressList
   }
  },
  

};
</script>

<style lang="less" scoped>
.head {
  background-color: #f4f4f4;
  height: 100vh;
  line-height: 30px;
  .head-top {
    display: flex;
    height: 30px;
    padding-top: 10px;
  }
  .tj {
    font-size: 18px;
    margin: 0 auto;
    line-height: 30px;
  }
}
</style>